text = input().split()
number = ''

for i in text:
    if i == 'zero':
        number += '0'
    if i == 'one':
        number += '1'
    if i == 'two':
        number += '2'
    if i == 'three':
        number += '3'
    if i == 'four':
        number += '4'
    if i == 'five':
        number += '5'
    if i == 'six':
        number += '6'
    if i == 'seven':
        number += '7'
    if i == 'eight':
        number += '8'
    if i == 'nine':
        number += '9'


def is_prime(n):
    if not n % 2:
        return n == 2
    d = 3
    while d * d <= n and n % d:
        d += 2
    return d * d > n


num = int(number)

if 99 < num < 1000:
    tmp = abs(num - 2)
    res = 2
    k = 3
    while True:
        if is_prime(k):
            t = abs(num - k)
            if t < tmp:
                tmp = t
                res = k
            else:
                print(res)
                break
        k += 2
else:
    print('Wrong input')
